package com.example.travelhelper.service.serviceImpl;


import com.example.travelhelper.mapper.UserMapper;
import com.example.travelhelper.pojo.User;
import com.example.travelhelper.service.UserService;
import com.example.travelhelper.utils.ResponseData;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.UUID;

@Service
public class UserServiceImpl implements UserService {
    /*
登录逻辑：
用户评论前进行登录验证，如果查询到此电话
号码已经存在数据库那就登陆成功，存在或验证通过后给前端返回token
 */
    @Autowired
    UserMapper userMapper;
    @Override
    public ResponseData login(String telephone)
    {
        User user = new User(UUID.randomUUID().toString(), telephone,null);
        try {
            userMapper.insert(user);
        }catch (Exception e){
            System.out.println("号码已经存在");
            e.printStackTrace();
        }finally {
            return ResponseData.success("登陆成功",user);
        }



    }

    @Override
    public ResponseData findAll() {

        return ResponseData.success("成功",userMapper.selectList(null));

    }


}


